package com.lzy.cloud.upload.config;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.autoconfigure.PageHelperProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

/**
 * Created with IntelliJ IDEA.
 * Description: lzy-cloud-service
 *
 * @author: ellengou
 * @date: 2018-05-22 星期二
 * @time: 11:27
 */
@Configuration
@EnableConfigurationProperties(PageHelperProperties.class)
public class PageHelperConfig {

    @Autowired
    PageHelperProperties pageHelperProperties;

    @Bean
    public PageHelper getPageHelper() {
        PageHelper pageHelper = new PageHelper();
        Properties properties = new Properties();
        properties.setProperty("reasonable", pageHelperProperties.getReasonable());
        properties.setProperty("supportMethodsArguments", pageHelperProperties.getSupportMethodsArguments());
        properties.setProperty("params", pageHelperProperties.getParams());
        pageHelper.setProperties(properties);
        return pageHelper;
    }
}